Skip to content

feat(knowledge): knowledge-turso moves into objectstack — Apache-2.0, platform embedder and splitter, generations, the contract suite - #37388

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-463817
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-463817

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #37107

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 本地开发(默认 SQLite)和不用 PostgreSQL 的部署,现在也能用开源自带的向量知识库:向量存在项目数据目录下单独的 knowledge.db 文件里,中文检索可用;换嵌入模型时在旁边建新索引,建好再切换,旧索引在此期间照常回答。
  • 属于「知识检索平台化」专题:把原来放在 cloud 仓库的 libSQL 向量库搬进开源框架(Apache-2.0),改用平台统一的嵌入器和切分器,并通过与 pgvector 同一套契约测试。
  • 新包默认不启用,撤回只需不注册该插件;它绝不写平台自己的数据库文件;在没有 libSQL 原生构建的平台(Windows ARM)上照常启动,只是知识源回答「暂不可用」。
  • 已按第一轮复核修完:只认旧版完整表结构,不会误删登记表或别人的表;远程库每次请求有 10 秒上限(按单次请求计时,重建一整批也不会超时;超时只回滚、不会事后提交);并补上「限定范围检索」。
  • 要你做的:无(专题席位做差量复核;cloud 仓库删除旧包是另一张 cloud 卡)。

What changes

@objectstack/knowledge-turso moves into packages/plugins/knowledge-turso (Apache-2.0 LICENSE text, settling cloud ADR-0119 D5's mixed licence). Same package name; the next version publishes from here, in the fixed version group.

  • Its own libSQL database, never the platform's file. url option (file:, :memory:, libsql://), else file: + project root + /.objectstack/data/knowledge.db (defaultStoreUrl, for Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 to name). A URL naming objectstack.db, dev.db, standalone.db or the file OS_DATABASE_URL names (a URL or a bare path) is refused, compared percent-decoded, without case, as the file a link resolves to, and with SQLite's -wal / -shm / -journal side files read as their database (os-bob's Evaluate: can os dev's default database move from SQLite (better-sqlite3) to a local libSQL file (driver-turso)? #37106 measurement, comment 7143523345: two engines on one file lose rows). On a file: PRAGMA journal_mode = WAL and a busy timeout (busyTimeoutMs, default 5000). In one process all database work of one client runs through one queue: a write transaction holds its connection across awaits, and a second in-process writer would otherwise wait in SQLite's synchronous busy handler on the very thread the holder needs. On a remote URL each request is bounded on its own (requestTimeoutMs, default 10000): a statement, a document's batch (a write sends each document's statements as one batch, so a 100-document page is ~100 requests), opening a transaction, a commit or rollback. Past it the call answers 503 SERVICE_UNAVAILABLE naming requestTimeoutMs, and the queue moves on. A request that times out inside a write is followed by a rollback, never a commit; only a commit that itself times out may still land, and its remedy says so (writes are idempotent).
  • Platform embedder and splitter. The package's own embedding provider, hash embedder and chunker are deleted; it reads the kernel embedder service at each call (or embedder), reports embedding (model, dimensions, maxInputTokens), and declares capabilities.chunks.
  • Layout (card item 4). knowledge_generation (source_id, generation, fingerprint, recipe_hash, dim, model, state, created_at) with two partial unique indexes: one active and one building row per source; the second is the lock row that keeps one builder per source. One passage table per source and generation, knowledge_SOURCE_gN (chunk_id PK, document_id, source_record_id, organization_id, content, title, heading_path, doc_hash, chunk_hash, metadata, embedding F32_BLOB(dim)). Source ids are held to the spec's ^[a-z_][a-z0-9_]*$ before any SQL (refused 400 VALIDATION_ERROR); every value is a bind parameter. The unique index keeps one generation under construction per source, not one builder: a second beginBuild under the same fingerprint joins the build, one under another fingerprint replaces it, and the first builder's writes are then refused 409.
  • Generations (card item 5; ADR-0161 K7, K8 item 8). Writes go to the generation of the carried fingerprint (active or building), else 409 KNOWLEDGE_REBUILD_REQUIRED; a search under another fingerprint than the active one's is refused the same way ("is being rebuilt" while a build for it runs). beginBuild under a new fingerprint creates knowledge_SOURCE_gN+1 beside the active table; a build of a third fingerprint drops the unfinished one. completeBuild makes it active, records the recipe hash, drops the old table. indexStatus answers fingerprint, recipeHash and building. Unlike knowledge-pgvector (which refuses a second generation, knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101), this store runs the suite with generations: true.
  • Legacy table (card item 4, last bullet). A knowledge_SOURCE table of the cloud releases, recognised by exactly their seven columns and an F32_BLOB vector, is never served. A table of any other shape under a store name (the store's own generation table, another source's generation table, a table the store did not make in a shared database) is neither served nor dropped; openGeneration remakes a table only when it has the passage shape: search answers KNOWLEDGE_REBUILD_REQUIRED, a write outside a build is refused, beginBuild opens generation 1 as building, and completeBuild drops the legacy table.
  • Search. Exact cosine scan (vector_distance_cos) with the organization filter, the record scope and the metadata filter (JSON equality per top-level key) in the same WHERE, before ranking; hits carry docHash and headingPath. No DiskANN index: vector_top_k ranks before it filters, which breaks K8 item 9, and it is what made os-bob's 1,000 × 1,536 file 329 MB with a 21.8 s build. Measured here without it: 1,000 passages 8.3 MB, write 0.7 s, search ~5 ms; 10,000 passages 82 MB, write 7.2 s, search ~52 ms (Linux x64). Docs say so and point larger sources at pgvector.
  • Record scope (service-knowledge: search takes a record scope (scope: [{ object, ids }]) and hands adapters a typed filter they apply before ranking #37308, merged as 98b17fe), as knowledge-pgvector. A scope with no term that has ids answers [] before any query; terms are ORed inside the organization-filtered WHERE. A record term matches source_record_id; a metadata term matches a stored string or number equal to an id as text, or a list with such an element, by the field's stored key (bound, never a JSON path). Each term's ids go as one bound JSON array. The suite declares implements.scope: true.
  • listDocuments (card item 6), byte-order cursor, the generation writes go to. A passage whose chunk_hash is stored is not re-embedded; a passage removed by a concurrent write is re-planned (3 attempts), as in pgvector.
  • Degrades instead of crashing (os-bob comment, Windows on ARM). @libsql/client is imported lazily in start(); a failed load (no native build), an unopenable file or a refused URL registers the adapter unavailable: boot continues, healthCheck ok: false, every call 503 SERVICE_UNAVAILABLE, one-sentence message, reason in remedy.
  • Wiring (named in the claim). .changeset/config.json fixed group; pnpm-lock.yaml (no new external dependency: @libsql/client@0.18.0 is already in the lockfile); one ledger row @objectstack/knowledge-turso: [KNOWLEDGE_REBUILD_REQUIRED] in packages/spec/src/api/error-code-ledger.zod.ts (its docs mirror lists codes only, unchanged); packages/spec/llms.txt package count 77 → 78 (check:llms-txt demanded it).
  • Settings hint made false by this PR, fixed (claim amended). knowledge.manifest.ts: the Turso "Test connection" hint said the package "this platform does not ship", from the ObjectOS Cloud monorepo, and that a store with no URL reuses the tenant's primary libSQL connection; both are now false. It now names the plugin registered beside the knowledge service and its default file; header list updated; the two tests re-pinned as properties. Minimal, as Knowledge settings page: every key has a reader or leaves the page (adapter, chunk_target, chunk_overlap, over_fetch, enforce_rls) #37104 rewrites this manifest.
  • Docs. content/docs/protocol/knowledge.mdx new section 4.2, overview diagram, contract paragraph, example, status table; content/docs/ai/knowledge-rag.mdx new section "Local vector store: a libSQL file".

Why

Card #37107 (ADR-0161 Execution row 7; cloud ADR-0119 D5 「都放开源」): every deployment not on PostgreSQL, os dev included, gets an open vector store that follows the platform's embedder, splitter, listing and fingerprint contract.

Tests

packages/plugins/knowledge-turso, 143 cases, no service or image (libSQL runs in-process):

  • contract.test.ts — runKnowledgeAdapterContract with every member declared (listDocuments, chunks, organizationIds, indexStatus, builds, refusesOtherFingerprint, generations, scope) on :memory: and on a file: URL: 92/92.
  • acceptance.test.ts (42, both stores plus two request-bound cases): Chinese text found with a fixed fake embedder; same content re-upserted → no embed call, changed passage → only it embedded; model changed at the same width and at another width → through KnowledgeService the search is refused, a complete reindex builds _g2, _g1 is dropped, the generation row records the new width and model; mid-build the old generation answers its own fingerprint and the new one is "being rebuilt", a third fingerprint abandons the unfinished build and a write under the abandoned fingerprint is refused; two organizations never see each other's hits (topK 1, filter before ranking); metadata filter by JSON type (2 vs "2"); legacy table → KNOWLEDGE_REBUILD_REQUIRED, write refused, indexStatus empty, then a reindex replaces and drops it; another source's generation table never read as legacy; a source named generation reindexed with the store's generation table intact and other sources still answering; a table the store did not make under a legacy name kept through a reindex, and under a generation name refused and kept; a passage table left without its generation row remade afresh, not adopted; a write whose generation is switched while it embeds refused 409, never written elsewhere; a record scope by stored key (a dotted name is a key), strings and numbers only (a boolean or object matches no id), a quote in a name, an injection-shaped id matching nothing; 12 concurrent upserts and searches on one :memory: client all succeed; an unsafe source id refused before SQL; no client / no embedder → SERVICE_UNAVAILABLE with the reason only in remedy, listDocuments included (503, not 409); a request that never answers is bounded by requestTimeoutMs and the queue moves on; on a slow client (15 ms a request, 120 ms bound) a page of 40 documents of 2 passages is written whole, twice; a write whose second batch hangs answers 503 naming requestTimeoutMs and nothing of it lands, then the next write goes through; a table with the legacy column names but no F32_BLOB vector is not legacy; a search whose generation is switched at every embed stops after three attempts (503); a source id outside the pattern is 400 VALIDATION_ERROR, an 80-character one accepted.
  • plugin.test.ts (9): default URL; platform database refused by name (percent-encoded and differently cased too) and by OS_DATABASE_URL (a URL or a bare path); an undecodable file: URL refused; side files and links (a linked file, a linked directory) refused; the remote default bound (requestBoundFor); the opened file is in WAL with the generation table; a @libsql/client that fails to load (mocked win32-arm64-msvc error) registers an unavailable adapter and boot continues; a kernel embedder registered after start is read.

Single-change ablations, each restored: the old legacy rule (4 red), openGeneration remaking a foreign table (2 red), the fresh-table DROP (2 red), listDocuments comparing before the embedder (1 red), the request bound (1 red), the old whole-turn bound (both request-bound cases red), a commit instead of a rollback after a timeout (1 red), the vector-type half (2 red), the VALIDATION_ERROR code (2 red), the search retry bound (2 red), the remote default (1 red), the side-file reading (1 red), the write-time generation recheck (2 red), the scope scalar guard (2 red), the scope WHERE (12 red in the suite).

Not covered here: two processes writing one file (the busy timeout is set and pinned by PRAGMA, not by a two-process race). Scope ids are compared with a stored number's SQLite text: exponent forms and numbers past 15 significant digits match no id here (fewer hits, never more; the service's check after the answer stays the guard).

Acceptance notes

  • carrier: cloud — packages/knowledge-turso in the cloud repo is now a duplicate; its removal is the cloud card the card names (out of scope). Nothing in cloud imports the package outside its own directory (searched cloud origin/main).
  • carrier: #37102 — the runtime mount names the store's path; defaultStoreUrl(projectRoot) and PLATFORM_DATABASE_FILES are exported for it.
  • noted, not filed — the knowledge settings namespace (turso_url, turso_auth_token) is still read by no plugin; Knowledge settings page: every key has a reader or leaves the page (adapter, chunk_target, chunk_overlap, over_fetch, enforce_rls) #37104 rewrites the manifest.
  • Breaking for npm consumers of the cloud-repo 6.x releases (removed exports and options, listed in the changeset); the version moves from 6.9.0 to this repo's track.

Verification

Two-minute check: pnpm --filter @objectstack/knowledge-turso test → Test Files 3 passed (3), Tests 143 passed (143).

Read first: src/turso-adapter.ts beginBuild / completeBuild / writeTarget (generation switching), hasLegacy / openGeneration with tableShape in src/sql.ts (the legacy rule), the serial queue and its bound at its top, and src/plugin.ts resolveStoreUrl (the platform-file refusal).

Local gates at head 796b204: 133 of 134 derived families exit 0, 1 not measured; CI at 796b204: 62 success, 9 skipped, 0 failed
  • node scripts/pm/dispatch-gates.mjs --ran (with exit codes): 134 derived famil(ies) accounted for, 133 run, 1 NOT-MEASURED (1 derived from a recorded exit 3).
  • pnpm --filter @objectstack/knowledge-turso test: Test Files 3 passed (3), Tests 143 passed (143) (lock VERDICT command-exit 0). typecheck (incl. check:test-typecheck) and build exit 0.
  • service-settings: knowledge.manifest.test.ts 25/25; typecheck exit 0.
  • check:llms-txt green at 78 packages. check:error-code-provenance, check:docs, check:package-naming, check:changeset-no-major, check:dual-build-cjs-loads, check:published-readme-exports, check:skill-examples exit 0 at this head.
  • NOT MEASURED locally (exit 3, prerequisite not met): check-plugin-teardown-shape --self-test (needs an unshallow clone; its scan passed).
  • No .github/workflows edit: the libSQL suite runs in the normal test shards, no service image needed. Dogfood battery: n/a (no ! in the title, no narrowing arm).
  • History: 56f3dc5e (first hand-back) → 68654e1d merges main at db77cc49 (brings feat(service-knowledge): search inside chosen records — the record scope, by the records a source indexes or by a parent through a listed lookup #37342) → 9c469ddf the record scope → f073750a review round 1 (seat comment 7179839476) → 796b204c review round 2 (seat comment 7180860083).

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed (none change for a ledger row; check:error-code-provenance and check:docs green).
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/knowledge-turso, @objectstack/service-settings, @objectstack/spec, touching 90 documentable anchor(s). ⚠️ 6 changed file(s) yielded no anchor (packages/plugins/knowledge-turso/LICENSE, packages/plugins/knowledge-turso/README.md, packages/plugins/knowledge-turso/package.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

26 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json e8740c55f0eaba7571c16a5588c833fe29e176ac.

⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 6 changed file(s) yielded no anchor (packages/plugins/knowledge-turso/LICENSE, packages/plugins/knowledge-turso/README.md, packages/plugins/knowledge-turso/package.json, …) — pages documenting those are invisible to this run
  • 2 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 38 pages), organization_id (literal, 42 pages)
  • 27 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 178 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json e8740c55f0eaba7571c16a5588c833fe29e176ac → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7295f1ec7e399880b6b41d91bd65e741c25b6058 — the merge of head 796b204c685c9299058ff00a1912799d2d811fa8 into base e8740c55f0eaba7571c16a5588c833fe29e176ac, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7295f1ec7e399880b6b41d91bd65e741c25b6058 && git checkout 7295f1ec7e399880b6b41d91bd65e741c25b6058
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e8740c55f0eaba7571c16a5588c833fe29e176ac 796b204c685c9299058ff00a1912799d2d811fa8 && git checkout -B drift-repro e8740c55f0eaba7571c16a5588c833fe29e176ac && git merge --no-ff 796b204c685c9299058ff00a1912799d2d811fa8

node scripts/docs-audit/affected-docs.mjs --json e8740c55f0eaba7571c16a5588c833fe29e176ac

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs e8740c55f0eaba7571c16a5588c833fe29e176ac → pass the list as
args.docs, on the commit named under Which tree this was computed on.

Brings #37342 (record scope). Conflict in content/docs/protocol/knowledge.mdx's
adapter table: both rows kept.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
…ng (ADR-0161 K8 item 17)

Mirrors knowledge-pgvector's scope from #37342: the terms are ORed inside
the organization-filtered WHERE, a record term on source_record_id, a
metadata term on a stored string or number equal to an id as text or a list
with such an element. Ids go as one bound JSON array per term; a field name
is a bound value compared with the stored keys, never a JSON path. A scope
with no term that has ids answers [] before any query. The contract suite
runs with implements.scope: true.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 这个 PR 把原来放在 cloud 仓库的 libSQL 向量库搬进开源框架:本地开发和不用 PostgreSQL 的部署,可以把向量存在自己的一个 knowledge.db 文件里。
  • 复核结论:暂不通过,退回开发补一轮。主要问题一处:识别"旧版本留下的表"的规则太宽。知识源如果恰好取了某一个合法名字,第一次完整重建索引就会删掉这个库自己的登记表,之后所有知识源都无法检索,重启后索引要全部重建;与别的表共用一个数据库时,同名规律的无关表也会被删。本机已复现。
  • 审核期间 PR 更新过一次:合并了主干,并补上了"限定范围检索"。这部分复核没有问题,范围过滤在数据库里、排序之前执行,查不到的方向只会少返回,不会多返回。
  • 另有三处应改:连接远程 libSQL 没有超时;两条从 pgvector 那轮定下的约定没有测试钉住;文档有两句话和现状不符,PR 正文的数字也还停在旧版本。
  • 自动检查还在跑(36 项未完成),目前没有失败项。
  • 需要您做的:无。cloud 仓库删除旧包仍是另一张 cloud 卡,要点列在下面"范围外去向"。

席位核对

REWORK — M1 is open at this head: the rule that recognises a table of the package's earlier releases is too wide, and a complete reindex can drop a table that is not one, the store's own generation table included. S1 to S3 stand beside it. The merge of main and the record scope, owed since #37342 landed, are in this head and hold.

Head-sha: 9c469ddf28f8f1c0aab5e3b8e74d736550285c06

Read in two parts. First the PR at 56f3dc5e2b10819f33ec24cd19c81d19b987dec9 (4 commits, 23 files, +2331 / -37). Then the delta, no force push: 68654e1d merges main at db77cc49, and 9c469ddf adds the record scope (8 files of the PR's own: the adapter, sql.ts, two test files, the README, the changeset, two docs pages). The PR against main at this head: 23 files, +2390 / -37, the same 23 paths as before.

形态

  • Open, draft, base main, first line Fixes #37107, the only closing keyword in the body. Fixes is right: every numbered item of the card is delivered; removing the package from the cloud repo is the card's own out-of-scope line.
  • Body and changeset read Clause-②: yes · Metadata-protocol: none. The changeset names @objectstack/knowledge-turso, @objectstack/spec and @objectstack/service-settings at patch; the new package joins the fixed group in .changeset/config.json.
  • Not governed surface: check-governed-merges.mjs --pr 37388 reads 0 of 23 paths on the register, 2427 changed lines, under the 3000 threshold. No .github/workflows path.
  • Every path is inside the claim as amended twice (comment 7177625794): the ledger row, and the Turso hint with its header list and test. The ledger's generated mirror lists codes only and does not change. packages/spec/llms.txt (77 to 78 packages) is the generated package count a gate demands.
  • LICENSE is the Apache-2.0 text, byte for byte the root LICENSE and the one of knowledge-pgvector; package.json says Apache-2.0.
  • mergeable_state is blocked.

门禁 check-runs (at 9c469ddf, read 2026-11-26)

  • 22 success, 9 skipped, 36 in progress, 0 failed. Lint · repo & tooling gates and the other Lint jobs read success, bar PM dispatch-gates and Lint UI, still running. Type Check · source gates success; workspace, consumer gates, debt ledger and UI not measured. Test Core, all ten shards, and Test UI, all sixteen: not measured. Build Core, Build Docs: not measured. All-green: not measured.
  • Temporal Conformance (live PG + MySQL) is an expected skip on the PR.
  • Local at 9c469ddf in a scratch worktree: knowledge-turso vitest 125/125 (3 files; the dev reports 124), typecheck with check:test-typecheck exit 0. Local at 56f3dc5e: 103/103, as the dev reports.

对照 knowledge-pgvector 的约定 (#37337)

  1. Coded refusals carry a remedy; driver text only there — holds. KNOWLEDGE_REBUILD_REQUIRED and both SERVICE_UNAVAILABLE shapes have one-sentence messages; the load failure, the open failure and the file name travel in remedy. The no-embedder refusal has no remedy, as in the reference.
  2. Embedder resolved before any fingerprint compare — holds on search and on listDocuments. Pinned on search (1 red when moved); not pinned on listDocuments (fix 3).
  3. A first generation never adopts leftover rows — holds in code (the table is made afresh); not pinned (fix 3).
  4. docHash and headingPath on hits — holds; 4 red when left off.
  5. Organization filter before ranking — holds, in the inner WHERE; 4 red when dropped.
  6. Chunk-hash skip — holds; 2 red when removed.
  7. No cached kernel embedder — holds; a getter read at each call, pinned.
  8. A connection timeout — holds for a file (the busy timeout); absent for a remote URL (fix 2).
  9. No raw driver text to search_knowledge callers — holds. A libSQL error carries no status, so the service reads it as uncoded and logs it.

逐项核对与消融 (21 single-change ablations in a scratch worktree, each restored; worktree removed)

  1. Generations — beginBuild opens a table beside the active one, takes up a build of the same fingerprint, drops one of another; completeBuild switches inside one transaction. The switch made at beginBuild instead: 4 red. The fingerprint compare removed from search: 4 red.
  2. Legacy table — refused on search (2 red when removed), dropped at completeBuild (2 red when kept). The recognition rule is too wide: fix 1.
  3. One builder per source — the unique index holds one generation under construction per source. It does not refuse a second builder: a second beginBuild under the same fingerprint joins the build, and under another fingerprint replaces it, after which the first builder's writes are refused 409. No mixed generation results either way. Probed locally. Accepted as a deviation from the words of K7 rule 3, which the contract gives an adapter no way to meet (no builder identity); the prose is fix 4.
  4. The in-process queue — holds; made pass-through, the concurrency case is red with TRANSACTION_ACTIVE and SQLITE_BUSY. Embed calls run outside it.
  5. SQL — table names come from a source id held to the whitelist and an integer, and the mapping from source and generation to a name is one to one. Every value is a bound parameter: organization ids, scope ids, field names, filter keys and values, cursors, document ids. Whitelist removed: 2 red.
  6. Tenant isolation — the organization filter is on the one ranked read; a search reads the active generation only, and one under construction is never ranked. listDocuments and delete are service-side and take no caller filter, as in the reference.
  7. The platform-file refusal — holds by name and by OS_DATABASE_URL; 2 red when removed. It reads spellings, not files: fix 5.
  8. Secrets — the auth token is handed to the client only. Four malformed URLs carrying a credential were tried: no warning, remedy or health message echoed it.
  9. Degrading — a failed @libsql/client load registers an unavailable adapter; rethrown, 1 red.
  10. Record scope (delta) — an empty scope answers nothing before any query; terms are a union inside the inner WHERE beside the organization filter; ids and the field name are bound; hits carry the document's metadata. Scope WHERE dropped: 14 red. Early return removed: 2 red. Union made an intersection: 2 red.
  11. Record scope, numbers (delta) — 19 stored numbers probed against the service's String(value). Whole numbers and short decimals match. Seven do not (exponent forms, more than 15 significant digits): each is a miss in SQL. Where SQL's text is shorter than the service's, the service's check after the answer drops the hit. Fewer hits, never more: fix 6.
  12. Merge (delta) — one conflict, the adapter table row of knowledge.mdx; both rows kept. No file of this PR outside the eight changes between the two heads.

逐句核的散文面

  • Changeset: every bullet read against the code. True, except "One builder per source, held by a unique index" (fix 4).
  • content/docs/protocol/knowledge.mdx §4.2, the diagram, the contract paragraph, the example, the status row: true as written; the scope clause matches the code.
  • content/docs/ai/knowledge-rag.mdx: "so os dev on SQLite gets semantic search … with nothing to install" is not true today: the package is added and the plugin registered by hand until Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 (fix 4). The rest is true.
  • README: true, except the same builder sentence.
  • knowledge.manifest.ts hint and header: true today. Nothing mounts the store from settings until Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102; "registered beside the knowledge service, with this URL" says so, and the no-URL text names the plugin's own default file.
  • PR body: stale at this head. It says 103 cases and "whichever lands second owes the other's suite cases", and its local-runs block is pinned to 56f3dc5e (fix 4).

修复清单

  1. M1 · 必须修 — the earlier-release table is recognised by one missing column alone, so a table that is not one can be taken for one and dropped by a complete reindex; the store's generation table is reachable this way through a legal source id. Recognise it by its own shape, keep the generation table out by name, and pin both. Reproduced locally at both heads; the steps are in the seat's reply, not here.
  2. S1 · 应修 — no bound on a call to a remote database. Boot awaits the health check, and one stalled request holds the queue of every source on that client. Bound it, as the reference does with its connection timeout.
  3. S2 · 应修 — two conventions of the reference are not pinned: a first generation made afresh (the DROP removed: 125 green), and listDocuments with no embedder answering 503 and not 409 (the order changed: 125 green).
  4. S3 · 应修,散文面 — prose: "nothing to install"; "one builder per source" in the changeset, README, knowledge.mdx and TSDoc, which should say what the index holds; the PR body re-pinned to this head.
  5. nit — the platform-file refusal compares spellings: an encoded or differently cased name, and a database named by a flag or a bare path, are not caught. A foot-gun guard for an operator's own option, not a boundary.
  6. nit — scope and filter numbers in exponent form or past 15 digits are in no scope on this adapter; in one shape the service then logs that the adapter does not apply the scope.
  7. nit — a source id the spec allows but longer than 48 characters is refused uncoded; SQLite has no such limit.
  8. nit — not pinned: the generation recheck inside the write transaction, and the scalar-type guard of a scope term (each removed: 125 green). The third-attempt write error names a made-up passage id; the search retry on a switched generation has no bound.

接受的偏差

  • No DiskANN index and so no vector_top_k on the CI runner (card item 6): the exact scan is what K8 item 9 needs, and vector32 runs in the test shards.
  • A second builder joins or replaces rather than being refused (point 3 above).
  • Two processes writing one file are covered by the busy timeout's PRAGMA pin, not by a two-process case.

范围外去向

落地条款

  • Clause-② declared and the path limb hit; the contract record below is FAIL at this head. The PR stays draft. A patch round to the same dev: M1 with its tests, then S1 to S3. A head that moves past prose owes a fresh record; every check at the landing head green or an expected skip before the queue.

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9c469ddf28f8f1c0aab5e3b8e74d736550285c06
Local-runs: probe — the package suite at both heads, 21 single-change ablations, and probes of the legacy rule, the builder lock, the store URL and the scope's number reading were run in a scratch worktree to confirm what the diff reads as; nothing was pushed.
Scope: packages/spec/src/api/error-code-ledger.zod.ts + packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts, packages/plugins/knowledge-turso/src/plugin.ts, packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/src/tests/contract.test.ts, packages/plugins/knowledge-turso/src/tests/acceptance.test.ts, packages/plugins/knowledge-turso/package.json
Security-touching: yes
Rule-change-verified: yes

① Derived judgments

  • The diff adds no contract member. It is the reader K8 item 16 names: items 1, 5, 7, 8 and 9 and nothing past them, with the generation table and lock row inside the adapter (K7 rule 2). The delta adds the reader of item 17 as the dated note of 2026-11-25 shapes it.
  • The one published-schema line is the ledger row for @objectstack/knowledge-turso, the same code and status the row of knowledge-pgvector registers. Its comment says the code also covers a source whose only index is an earlier-release table; the adapter does throw it there.
  • K7 rules 1, 4 and 5 hold: a write goes to the generation of the fingerprint it carries or is refused; a search under another fingerprint than the active one's is refused and never answered from it; no query ranks two generations.
  • K7 rule 3 holds in part: a build is opened only by beginBuild, and an unfinished one is resumed or replaced. "Refuses a second builder" is not met and cannot be with what the contract carries; recorded as an accepted deviation by the seat.

② Semver level

  • Clause-②: yes, Metadata-protocol: none: right. A new published package widens the public surface; no metadata key changes.
  • patch for all three packages is what the fixed group and the no-major gate take. The package name is published at 6.9.0 from another repository, and the changeset lists the exports and options removed against those releases, which is where a consumer of them reads the break.
  • @objectstack/spec at patch: one additive ledger row and a package count.

③ Boundary flags

④ Design judgment

packages/spec/src/api/error-code-ledger.zod.ts

  • Holds. One row, additive, the code already registered for the sibling store; the comment is true of the adapter.

packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts

  • The refusal the ledger row registers is thrown with code, status 409, a one-sentence message and a remedy, on a write and on a search, and the acceptance cases assert code and status.
  • The earlier-release path does not hold as designed.

M1 (must-fix) — the rule that recognises an earlier-release table is too wide: a table that is not one is refused as one and then dropped by a complete reindex, the store's own generation table among them. After that every source of the store fails until a restart and is then rebuilt from nothing. It is reachable through a source id the spec allows. Reproduced at both heads.

  • The record scope agrees with the term type and with the reference's reading: a record term on the stored record id, a metadata term on a stored string or number as text or any such element of a list, anything else matching nothing, an empty scope ranking nothing.

packages/plugins/knowledge-turso/src/plugin.ts

  • The store never opens the platform's file by default, and the refusal of a named platform file holds for the spellings the docs list. The plugin registers an unavailable adapter instead of failing the boot.

S1 (should-fix) — a call to a remote database has no bound, while boot awaits the health check and one queue serves every source of the client.

packages/plugins/knowledge-turso/src/__tests__/contract.test.ts, packages/plugins/knowledge-turso/src/__tests__/acceptance.test.ts

  • Every member of the suite is declared and runs on both stores, with no service image.

S2 (should-fix) — two conventions of the reference are held in code and pinned by no case: the first generation made afresh, and listDocuments with no embedder.

packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/package.json

Implemented-by: session_01JQwxbaMuehXzctoWq7iRsV
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: FAIL

…ape, a bound on remote calls, the conventions pinned

- A table of the cloud-repo releases is recognised by exactly their columns
  and an F32_BLOB vector, never by one missing column: the store's own
  generation table and a table it did not make (a shared database) are
  never refused as one nor dropped by a reindex. openGeneration makes a
  table afresh only when it is one of the store's passage tables, and
  refuses any other table under that name.
- requestTimeoutMs bounds one turn of the per-client queue (default 10000 on
  a remote URL): past it SERVICE_UNAVAILABLE, and the queue moves on.
- Pinned: a first generation made afresh; listDocuments without an embedder
  is 503, not 409; the write-time generation recheck; the scope scalar guard.
- The platform-file refusal compares the percent-decoded path, without case,
  and a bare-path OS_DATABASE_URL; an undecodable file: URL is refused.
- A spec-valid source id of any length is accepted; a refused one carries
  VALIDATION_ERROR 400. The search retry on a switched generation is
  bounded; the third-attempt write error names no synthetic passage id.
- Prose: the unique index keeps one generation under construction, not one
  builder; os dev does not mount the store yet.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 这一轮只看开发按上轮意见改的那一个提交。上轮的主要问题已经修好:现在只有列结构与旧版本完全一致的表才会被当成"旧版本留下的表",这个库自己的登记表和别人的表都不会再被误删。本机用五种情况重新试过,都对。
  • 另外三处应改项也都改了,文档和 PR 正文与现状一致。自动检查全部通过(64 项通过,11 项按设计跳过,0 项失败)。
  • 复核结论:还差一处,再退回补一小轮。新加的"远程数据库超时"是按一整批写入来计时的,默认 10 秒。重建索引时一批是 100 条记录、几百条语句;连接远程 libSQL 时,稍慢一点的网络就会超过 10 秒,于是每次重建都在第一批停下,换模型后的新索引永远建不完。本机按比例模拟复现了,没有在真实远程库上测。
  • 本地文件方式(本卡的主要用途)不受影响:文件和内存库默认不设这个超时。
  • 需要您做的:无。

席位核对

REWORK — M1 and S1 to S3 of round 1 are closed at this head, and every check is green. One new finding, S4, came in with the fix for S1: the bound on a remote call is taken over a whole queue turn, and a write turn is a whole page of documents. A small patch round.

Head-sha: f073750af7c4b688d3ecc8be57a13c75766c97ac

Delta review: one commit on 9c469ddf28f8f1c0aab5e3b8e74d736550285c06, no force push; 9 files, +315 / -56, all of them the package's own, its two docs pages and its changeset. The PR against main: the same 23 paths, +2649 / -37. The rest stands as read in round 1 (PR comment 7179839476).

形态

  • Open, draft, base main, first line Fixes #37107, still the only closing keyword. Declaration lines unchanged on body and changeset.
  • Not governed surface: check-governed-merges.mjs --pr 37388 reads 0 of 23 paths on the register, 2686 changed lines, under the 3000 threshold.
  • mergeable_state is clean; main is 10 commits ahead and a trial merge has no conflict.
  • The PR body is re-pinned to f073750a: 135 cases, the head history, the scope's number reading named as not covered.

门禁 check-runs (at f073750a, read 2026-11-26)

  • 64 success, 11 skipped, 0 failed, 0 in progress. Lint & Repo Gates success; TypeScript Type Check success with its four parts; Test Core success, all ten shards; Test UI success, all sixteen; Build Core, Build Docs success. All-green: yes, with expected skips only.
  • Temporal Conformance (live PG + MySQL) is an expected skip on the PR.
  • Local at f073750a in a scratch worktree: knowledge-turso vitest 135/135 (3 files), typecheck with check:test-typecheck exit 0. The dev's count agrees.

上轮各项的复核 (16 single-change ablations at this head, each restored; worktree removed)

  1. M1, closed — an earlier-release table is now one with exactly the seven columns of those releases and an F32_BLOB vector, checked against the DDL in the cloud repo; the generation table is excluded by name as well. Re-probed: a source named after the generation table builds and searches, and every other source keeps answering; a table of another shape under an earlier-release name is neither refused nor dropped and keeps its rows; a real earlier-release table with its vector index is refused 409, then dropped with its index tables; a table of another shape under a generation name stops the build and is kept. The old rule put back: 4 red. The column test loosened to a subset: 4 red. The remake guard removed: 2 red.
  2. M1, what remains by design — a table the store did not make that has exactly the earlier-release columns is taken for one and dropped by a complete reindex. Nothing tells the two apart, and the README and the protocol page now say the rule is the exact columns.
  3. S1, closed — a turn of database work is bounded when requestTimeoutMs is set, 10000 by default for a remote URL, none for a file or :memory:. A server that never answers: boot returned in 402 ms under a 400 ms bound with a warning that carried no credential; later calls answer 503; when the server answers again the next call succeeds, and a build begun afterwards opens normally. The queue and the generation row are not left held. The bound removed: 1 red. What it bounds is S4.
  4. S2, closed — both conventions are pinned: the first-generation DROP removed, 2 red; listDocuments comparing before the embedder, 1 red.
  5. S3, closed — "no database server to run", with the sentence that the package is added and registered by hand until os dev mounts it; the builder sentence now says what the index holds, in the changeset, the README, the protocol page and the TSDoc; the PR body is at this head.
  6. Round-1 nits — the platform-file refusal now decodes, folds case and reads a bare-path platform URL (each undone: 1 red); the source id follows the spec's own pattern and its refusal is VALIDATION_ERROR 400; the search retry stops at three; the write error no longer names a made-up passage; the write-time recheck and the scope's scalar guard are pinned (2 red each). The scope's number reading is left as it was, fail closed, and the body says so.

逐句核的散文面 (delta sentences)

  • Changeset: the requestTimeoutMs sentence and the rewritten builder sentence — true. The first is true of what the code does, which is the subject of S4.
  • content/docs/ai/knowledge-rag.mdx: "with no database server to run. Until os dev mounts it for you, add the package and register KnowledgeTursoPlugin beside the knowledge service yourself." — true.
  • content/docs/protocol/knowledge.mdx §4.2: the builder clause; "a source id that is not snake_case is refused"; "with exactly their columns"; "A table of any other shape under one of the store's names is neither served nor dropped." — true.
  • README: the requestTimeoutMs row, the builder sentence, the exact-columns sentence — true.

修复清单

  1. S4 · 应修 — the request bound covers a whole queue turn, and the write turn is one transaction holding a statement per document and per passage of the page. On a remote database a page of 100 documents is several hundred round trips, so the default 10 s is passed at a few tens of milliseconds each; the write answers 503, the reindex stops, and the next attempt meets the same bound. A rebuild under a new fingerprint then never completes. The stalled turn keeps running and can commit after the caller was told 503. Bound each statement and the commit, or send a document's statements together, name the option in the remedy, and pin it with a slow client. Simulated in proportion here; not measured on a real remote database.
  2. nit — the platform-file refusal still reads names, not files: a link to the platform file and the platform file's own side files are not caught. One malformed file URL ends the process inside the native client instead of degrading; it did before this PR too. Both are an operator's own option today; the steps are in the seat's reply.
  3. nit — not pinned: the vector-type half of the shape test, the code of the source-id refusal, the bound on the search retry, and the remote default itself (each undone: 135 green).
  4. nit — search now has a third parameter, the retry count, on the published class.
  5. nit — a table of another shape under a generation name stops that source's build with an uncoded error.
  6. nit — the scope's number reading, unchanged from round 1.

接受的偏差 (unchanged, plus one)

  • As in round 1. New: a table with exactly the earlier-release columns is treated as one whoever made it (point 2 above).

范围外去向

落地条款

  • Clause-② declared and the path limb hit; the contract record below is FAIL at this head for S4 alone. The PR stays draft. A patch round to the same dev: S4 with its case. A head that moves past prose owes a fresh record, a delta read by this reviewer.

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f073750af7c4b688d3ecc8be57a13c75766c97ac
Local-runs: probe — the package suite, 16 single-change ablations, and probes of the earlier-release rule, the request bound and the store URL were run in a scratch worktree to confirm each fix of round 1; nothing was pushed.
Scope: packages/spec/src/api/error-code-ledger.zod.ts + packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts, packages/plugins/knowledge-turso/src/plugin.ts, packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/src/tests/contract.test.ts, packages/plugins/knowledge-turso/src/tests/acceptance.test.ts, packages/plugins/knowledge-turso/src/tests/plugin.test.ts, packages/plugins/knowledge-turso/package.json
Security-touching: yes
Rule-change-verified: yes

① Derived judgments

  • Round 1 stands: no contract member is added; the adapter reads K8 items 1, 5, 7, 8, 9 and 17 and nothing past them. The delta changes no contract text and no spec file.
  • The delta adds one option, requestTimeoutMs, on the adapter and the plugin, and one coded refusal the package did not throw before, VALIDATION_ERROR 400 for a source id outside the spec's pattern. That code is a platform code, not a package one, so the ledger row is right as it stands.
  • The whitelist for a table name is now the spec's own pattern for a source id, with no length cap. The mapping from source and generation to a table name is still one to one, and every name is still quoted.

② Semver level

  • Unchanged: Clause-②: yes, Metadata-protocol: none, patch in the fixed group. The new option is additive and optional.

③ Boundary flags

  • Dev flags and open_questions: none open.
  • SQL push-down: unchanged; the shape test reads pragma_table_info for one bound name. No finding.
  • Author: PR user.login is objectstack-fleet[bot].
  • Overlap: none open on these files at this head; main merges without conflict.

④ Design judgment

packages/spec/src/api/error-code-ledger.zod.ts

  • Holds as in round 1; untouched by the delta.

packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts

  • The earlier-release path now holds: the refusal the ledger comment names is thrown only for a table of exactly that shape, and only such a table is dropped.

M1 (must-fix): closed.

  • The request bound holds for a read and for a database that does not answer. It does not hold for the write turn.

S4 (should-fix) — the bound is taken over a whole queue turn, and a write turn is a page of documents in one transaction, so against a remote database the default is passed by an ordinary page: the write answers 503, the reindex stops there every time, and a rebuild under a new fingerprint does not complete. Simulated in proportion; not measured on a real remote database.

packages/plugins/knowledge-turso/src/plugin.ts

  • The remote default is applied only to a remote URL; a file and :memory: keep no bound, so the store the card is for is not touched by S4.

S1 (should-fix): closed.

packages/plugins/knowledge-turso/src/__tests__/contract.test.ts, packages/plugins/knowledge-turso/src/__tests__/acceptance.test.ts, packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts

  • The cases added pin what round 1 asked for; each turns red under its ablation.

S2 (should-fix): closed.

packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/package.json

  • Hold as in round 1; untouched by the delta.

Implemented-by: session_01JQwxbaMuehXzctoWq7iRsV
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: FAIL

… never per page; a write stopped is rolled back

- requestTimeoutMs bounds each request on its own (a statement, a batch,
  opening a transaction, a commit or rollback) through a bounded view of the
  client, no longer a whole queue turn; the queue stays keyed by the client
  as given. A write sends each document's statements as one batch, so a page
  of 100 documents is ~100 requests. A request that times out inside a
  write is followed by a rollback, never a commit; only a commit that times
  out may still land, and its remedy says so. The remedy names
  requestTimeoutMs. Pinned with a slow client (40 documents, 2 passages
  each) and a write whose second batch hangs (nothing of it lands).
- search's retry count is a private method's, not a third public parameter.
- A table the store did not make under a generation name answers
  SERVICE_UNAVAILABLE with the table in the remedy.
- The platform-file refusal compares the file a link resolves to, and reads
  SQLite's -wal, -shm and -journal side files as their database.
- Pinned: the vector-type half of the legacy shape, the VALIDATION_ERROR
  code (and a long source id accepted), the search retry bound, the remote
  default bound (requestBoundFor).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 这一轮只看开发按上轮意见改的那一个提交。上轮剩下的问题已经修好:远程数据库的超时现在按每一次请求计时,不再按一整批写入计时,一批再大也不会因此超时。本机用上轮同样的模拟重跑:原来两次都失败的那一批,现在两次都写成功。
  • 中途超时的写入会被撤销,不会留下半截数据;只有"提交"这一步超时才可能已经写入,错误说明里写明了这一点和该调的参数。
  • 复核结论:通过,可以转为正式 PR 并排队合并。自动检查全部通过(64 项通过,11 项按设计跳过,0 项失败)。
  • 留了一条小问题不拦合并:如果远程库连"开始事务"都超时、之后又迟迟返回,那个事务没人关,要等服务器自己回收。本地文件方式遇不到。建议随托管接入那张卡一起补。
  • 提醒:这个 PR 现在是 2922 行,离"超过 3000 行需人工合并"的线只差 78 行,所以不建议为小问题再加一轮。
  • 需要您做的:无。

席位核对

ACCEPT — S4 is closed at this head: the request bound is per request, a write sends one request per document, and a write stopped by the bound is rolled back. Nothing else moved. Every check is green. Nits only, the first of them worth a follow-up with the hosted registration.

Head-sha: 796b204c685c9299058ff00a1912799d2d811fa8

Delta review: one commit on f073750af7c4b688d3ecc8be57a13c75766c97ac, no force push; 7 files, +280 / -44, all inside packages/plugins/knowledge-turso/ and its changeset. No docs page, no spec file and no settings file changed. The PR against main: the same 23 paths, +2885 / -37. The rest stands as read in rounds 1 and 2 (PR comments 7179839476, 7180860083).

形态

  • Open, draft, base main, first line Fixes #37107, still the only closing keyword. Declaration lines unchanged on body and changeset.
  • Not governed surface: check-governed-merges.mjs --pr 37388 reads 0 of 23 paths on the register, 2922 changed lines, under the 3000 threshold by 78.
  • mergeable_state is clean; main is 16 commits ahead and a trial merge has no conflict.
  • The PR body is pinned to 796b204c: 143 cases and the head history.

门禁 check-runs (at 796b204c, read 2026-11-26)

  • 64 success, 11 skipped, 0 failed, 0 in progress. Lint & Repo Gates success; TypeScript Type Check success; Test Core success, all ten shards; Test UI success; Build Core, Build Docs success. All-green: yes, with expected skips only. The dev's 62 and 9 are the same reading taken before two duplicate runs finished.
  • Temporal Conformance (live PG + MySQL) is an expected skip on the PR.
  • Local at 796b204c in a scratch worktree: knowledge-turso vitest 143/143 (3 files), typecheck with check:test-typecheck exit 0.

逐项核对与消融 (12 single-change ablations at this head, each restored; worktree removed)

  1. S4, the bound — every request goes through a bounded view of the client: a statement, a batch, opening a transaction, and a transaction's statement, batch, commit and rollback, each on its own. The queue is still keyed by the client as given, so adapters on one client share it. No bound inside a transaction: 1 red. No bound at all: 2 red.
  2. S4, the write — one batch per document inside the transaction, so a page of 100 documents is about 100 requests whatever the passage count. One request per statement put back: 1 red.
  3. S4, the round-2 simulation re-run — 100 documents of 3 passages, 4 ms per request, a 300 ms bound. Round 2: 503 both times. Now: written in 496 ms over 104 requests, the same page again in 471 ms, 300 rows, the build completed.
  4. A request that never answers, on a file store and on :memory:, at four places — the second batch of a write, the commit, a statement inside the transaction, and the rollback as well. Each time the write answers 503, the transaction is closed at once, nothing of the stopped write is stored, and the next search and the next write succeed. The single connection is not left held.
  5. The commit — a commit that passes the bound may still land; its remedy says so, says to retry, and names requestTimeoutMs. Every other timeout's remedy names the option and says to raise it.
  6. The one place a transaction can be left open — when opening the transaction is itself the request that passes the bound and it answers later, the transaction it returns is closed by nobody. Forced with a client whose open is slower than the bound: the file store then refuses the next write, and :memory: refuses every call. The in-process client opens a transaction in one step, so this is not reachable there with the real client; on a remote database it needs a server that answers the open after the bound, and the transaction then waits for the server to end it. Fix 1.
  7. The platform-file refusal — a link to the platform's file, a link to its directory and a chain of links are refused, and so are its -wal, -shm and -journal side files, with the platform file named by URL or by a bare path. Real path not read: 1 red. Side files not folded: 1 red.
  8. The other round-2 nits — the retry count is on a private method and search has its two parameters again; a table of another shape under a generation name answers a coded 503 with the table named in remedy only (uncoded again: 2 red); the vector-type half of the shape test, the code of the source-id refusal and the remote default are pinned (2, 2 and 1 red); the search retry left unbounded hangs its case.
  9. Nothing else moved — sql.ts is untouched; the earlier-release rule, the scope, the generations and the organization filter are as read in round 2, and their cases are in the 143.

逐句核的散文面 (delta sentences)

  • Changeset: "each request is bounded (requestTimeoutMs, default 10000; a write sends one request per document): past it the call answers SERVICE_UNAVAILABLE, a write stopped before its commit is rolled back, and the queue moves on" — true.
  • README: the requestTimeoutMs row ("each statement, each document's batch of a write, each commit … A write stopped before its commit is rolled back, never committed") — true. The platform-file sentence ("compared as the file a link resolves to and with SQLite's -wal, -shm and -journal side files read as their database") — true.

修复清单

  1. nit — a transaction whose open passed the bound and then arrived is never closed (point 6). Close it when it arrives. With the hosted registration, row 14, where a remote database is first used.
  2. nit — the platform-file refusal does not see a second hard link to the platform file, nor a side-file name written through a link. The malformed file URL of round 2 still ends the process inside the native client; the dev leaves it for Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 and Knowledge settings page: every key has a reader or leaves the page (adapter, chunk_target, chunk_overlap, over_fetch, enforce_rls) #37104, as agreed.
  3. nit — not pinned: the queue keyed by the client as given, and the commit wording of the remedy (each undone: 143 green).
  4. nit — requestBoundFor and DEFAULT_REQUEST_TIMEOUT_MS are now exports of the package; the first exists for a test.
  5. nit — the scope's number reading, unchanged since round 1.

接受的偏差 (unchanged)

  • As in rounds 1 and 2.

范围外去向

落地条款

  • Clause-② declared and the path limb hit; the contract record below is PASS at this head. Flip to ready and queue: every check at this head is green or an expected skip. main is 16 commits ahead with no conflict. A further commit of more than 78 changed lines takes the PR past the 3000-line threshold. A head that moves past prose owes a fresh record.

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 796b204c685c9299058ff00a1912799d2d811fa8
Local-runs: probe — the package suite, 12 single-change ablations, the round-2 write simulation, and probes of a request that never answers and of the store URL were run in a scratch worktree to confirm the fix of round 2; nothing was pushed.
Scope: packages/spec/src/api/error-code-ledger.zod.ts + packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts, packages/plugins/knowledge-turso/src/plugin.ts, packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/src/tests/contract.test.ts, packages/plugins/knowledge-turso/src/tests/acceptance.test.ts, packages/plugins/knowledge-turso/src/tests/plugin.test.ts, packages/plugins/knowledge-turso/package.json
Security-touching: yes
Rule-change-verified: yes

① Derived judgments

  • Rounds 1 and 2 stand: no contract member is added, and the adapter reads K8 items 1, 5, 7, 8, 9 and 17 and nothing past them. The delta changes no contract text and no spec file.
  • The delta changes how one option is applied, per request and no longer per queue turn, and adds two exports beside it. No coded refusal is added: the table found under a generation name now answers the SERVICE_UNAVAILABLE the package already throws.

② Semver level

  • Unchanged: Clause-②: yes, Metadata-protocol: none, patch in the fixed group. The package has not shipped from this repository yet, so the two new exports and the option's changed reading break no consumer.

③ Boundary flags

④ Design judgment

packages/spec/src/api/error-code-ledger.zod.ts

  • Holds as in round 1; untouched by the delta.

packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts

  • The request bound now holds for the write: it is taken per request, a document is one request, and a write the bound stops is rolled back and its transaction closed. The simulation that failed in round 2 succeeds.
  • A transaction whose open itself passes the bound is the one case not closed; recorded by the seat as a nit, with its reach.

S4 (should-fix): closed.

packages/plugins/knowledge-turso/src/plugin.ts

  • The remote default is applied to a remote URL only, and is now pinned. The platform-file refusal reads the real path and the side files.

packages/plugins/knowledge-turso/src/__tests__/contract.test.ts, packages/plugins/knowledge-turso/src/__tests__/acceptance.test.ts, packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts

  • The two cases added for the bound turn red under their ablations; the suite's members are declared as before.

packages/plugins/knowledge-turso/src/index.ts, packages/plugins/knowledge-turso/package.json

  • Hold. Two exports added; the entry point and the files shipped are as in round 1.

M1 (must-fix): closed.
S1 (should-fix): closed.
S2 (should-fix): closed.

Implemented-by: session_01JQwxbaMuehXzctoWq7iRsV
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

knowledge-turso moves into objectstack: Apache-2.0, the platform embedder and splitter, listing, generations, the contract suite

2 participants